package edu.sfsu.powerrangers.jeopardy.editor;

import java.awt.BorderLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import edu.sfsu.powerrangers.jeopardy.gamestate.FinalRound;

public class FinalRoundPanel extends JPanel {
	private static final long serialVersionUID = 1L;
	
	private JTextField categoryField;
	private JTextArea clueField;
	private JTextArea responseField;
	
	public FinalRoundPanel() {
		super(new BorderLayout(4,4));
		JLabel categoryLabel = new JLabel("Category:");
		categoryField = new JTextField();
		JPanel categoryPanel = new JPanel(new BorderLayout(4,4));
		categoryPanel.add(categoryLabel, BorderLayout.LINE_START);
		categoryPanel.add(categoryField, BorderLayout.CENTER);
		clueField = new JTextArea();
		clueField.setLineWrap(true);
		clueField.setWrapStyleWord(true);
		JScrollPane cluePane = new JScrollPane(clueField, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		responseField = new JTextArea();
		responseField.setLineWrap(true);
		responseField.setWrapStyleWord(true);
		JScrollPane responsePane = new JScrollPane(responseField, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		JTabbedPane crPane = new JTabbedPane();
		crPane.add(cluePane, "Clue");
		crPane.add(responsePane, "Response");
		add(categoryPanel, BorderLayout.PAGE_START);
		add(crPane, BorderLayout.CENTER);
	}
	
	public FinalRound getFinalRound() {
		return new FinalRound(categoryField.getText(), clueField.getText(), responseField.getText());
	}
	
	public void setFinalRound(FinalRound round) {
		categoryField.setText(round.getCategoryName());
		clueField.setText(round.getClue());
		responseField.setText(round.getResponse());
	}
}
